Skip to content

feat(web): add web generator #285

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

feat(web): add web generator #285

wants to merge 1 commit into from

Conversation

avivkeller
Copy link
Member

@avivkeller avivkeller commented May 28, 2025

Fixes #7.

This PR adds the web generator.

Tasks / Issues

P1 – Must Complete Before Merge

  • Fix notifications on CodeBox
  • Add more items (anyone can do this as they review1)

P2 – Must complete before migration

P3 – Can Be Done in a Follow-up

  • Remove mustache dependency
  • Adding a tooltip/expand to the DataTag
  • Use new Orama UI
  • Add more items (anyone can do this as they review1)

Get a preview

node bin/cli.mjs generate -t orama-db -i "/node/doc/api/*.md" -o "./out" # If you want search functionality
node bin/cli.mjs generate -t web -i "/node/doc/api/*.md" -o "./out" --index "/node/doc/api/index.md" # Specifying `--index` is optional, but recommended
npx serve out # You can serve the output, or just open one of the files in your browser. Serving is required for using search.

Footnotes

  1. Add things as they appear, or leave review comments. 2 3

@codecov-commenter
Copy link

codecov-commenter commented May 28, 2025

Codecov Report

Attention: Patch coverage is 53.89507% with 580 lines in your changes missing coverage. Please review.

Project coverage is 70.58%. Comparing base (f80bcce) to head (9d64e1d).

✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...nerators/jsx-ast/utils/createSignatureElements.mjs 30.37% 149 Missing ⚠️
src/generators/web/index.mjs 39.55% 81 Missing ⚠️
src/generators/jsx-ast/utils/buildContent.mjs 47.01% 71 Missing ⚠️
src/generators/web/build/generate.mjs 22.36% 59 Missing ⚠️
src/generators/web/build/css.mjs 24.19% 47 Missing ⚠️
src/generators/jsx-ast/utils/buildBarProps.mjs 36.92% 40 Missing and 1 partial ⚠️
src/generators/web/build/bundle.mjs 24.52% 40 Missing ⚠️
src/generators/jsx-ast/index.mjs 26.00% 37 Missing ⚠️
src/generators/orama-db/index.mjs 54.34% 21 Missing ⚠️
src/utils/queries/index.mjs 71.73% 10 Missing and 3 partials ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #285      +/-   ##
==========================================
- Coverage   72.17%   70.58%   -1.59%     
==========================================
  Files         117      128      +11     
  Lines        9936    10878     +942     
  Branches      597      633      +36     
==========================================
+ Hits         7171     7678     +507     
- Misses       2762     3193     +431     
- Partials        3        7       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@avivkeller avivkeller marked this pull request as ready for review May 28, 2025 22:13
@avivkeller avivkeller requested a review from a team as a code owner May 28, 2025 22:13
@avivkeller avivkeller marked this pull request as draft May 29, 2025 16:36
@avivkeller
Copy link
Member Author

avivkeller commented May 30, 2025

🎉 The code now dehydrates to the client so it can render without JavaScript!

@AugustinMauroy
Copy link
Member

🎉 The code now dehydrates to the client so it run without JavaScript!

Wow 😵‍💫 and what about codetab

@avivkeller
Copy link
Member Author

avivkeller commented May 30, 2025

It rehydrates and runs with JS, but if you don't have JS, you can still view the docs. I used React's SSRing

@avivkeller
Copy link
Member Author

@AugustinMauroy and I got search to finally work 🎉
image

@avivkeller avivkeller force-pushed the feat/web/gen branch 2 times, most recently from 024bbea to dbfe55d Compare June 3, 2025 21:40
@avivkeller
Copy link
Member Author

@nodejs/nodejs-website @nodejs/web-infra ChangeHistory and SideBar aren't implemented yet, so this is still a draft, but it's ready for you to take a look, so feel free to review :-)

@avivkeller avivkeller linked an issue Jun 6, 2025 that may be closed by this pull request
@avivkeller
Copy link
Member Author

Rebasing to include #347

@ovflowd
Copy link
Member

ovflowd commented Jul 10, 2025

Using Rolldown appears to reduce compile time significantly... if I can get it to work 😅

What piece is not working? 👀

@avivkeller
Copy link
Member Author

avivkeller commented Jul 10, 2025

What piece is not working? 👀

(Oops, I accidentally deleted the comment)

It's causing a SyntaxError in some of the compiled code, which I'm investigating. It has to do with the string interpolation 🤔

If you look at https://api-docs-tooling-7fvr17mt4-openjs.vercel.app/, it doesn't generate most of the documentation.

@avivkeller
Copy link
Member Author

🤦 I was using Math.random().toString(36).slice(2) to generate unique variable names, but forgot that that doesn't generate safe JavaScript variables (since it can start with a number). I needed to prefix it with _.

@avivkeller
Copy link
Member Author

Based on my estimates, it should decrease the compile time, but we will see.

@ovflowd
Copy link
Member

ovflowd commented Jul 10, 2025

Based on my estimates, it should decrease the compile time, but we will see.

Is the latest version using Rolldown?

@ovflowd
Copy link
Member

ovflowd commented Jul 10, 2025

node bin/cli.mjs generate -t web -i "../node/doc/api/*.md" -o "./out" --index  52.77s user 15.80s system 202% cpu 33.882 total

@ovflowd
Copy link
Member

ovflowd commented Jul 10, 2025

node bin/cli.mjs generate -t web -i "../node/doc/api/*.md" -o "./out" --index  52.77s user 15.80s system 202% cpu 33.882 total

Note that this is around 10s faster than the previous one. Are we still thinking on LightningCSS?

BTW, I still find impressive building all these react pages under 1 minute. They are huge long massive pages.

@avivkeller
Copy link
Member Author

avivkeller commented Jul 10, 2025

Note that this is around 10s faster than the previous one. Are we still thinking on LightningCSS?

The 10s improvement comes from LightningCSS + Rolldown, yes. Based on my testing, Rolldown is slightly faster than ESBuild, the LightningCSS is much faster than PostCSS, hence the improvement.

BTW, I still find impressive building all these react pages under 1 minute. They are huge long massive pages.

🎉 (My goal to make them even faster 🚀)

@avivkeller
Copy link
Member Author

avivkeller commented Jul 11, 2025

@nodejs/collaborators @nodejs/web-infra @nodejs/nodejs-website

If you could be so kind as to review https://api-docs-tooling.vercel.app/ and come up with a list of things that still need to be completed, it would be helpful. I know it's a bit tedious, but it'll help with the development significantly.

Note that we are aware of the following issues:

Note that we are in the process of making the following improvements:

  • Increasing the depth of the right-hand side ToC
  • Adding a tooltip/expand to the DataTag, which explains what it refers to (@ovflowd, would you mind opening an issue in nodejs/nodejs.org?)
  • A visualization of the extends keyword (which, I still need to design)
  • Improving the UX of the Mobile Table Design, see Poor Table UX on Mobile nodejs.org#7656

@Qard
Copy link
Member

Qard commented Jul 12, 2025

Random thought which may have already been considered:

Given that we at this point have TypeScript support via type erasure, and this new design has a nice integrated format switcher, should we start allowing TypeScript examples to be added too?

@avivkeller
Copy link
Member Author

Given that we at this point have TypeScript support via type erasure, and this new design has a nice integrated format switcher, should we start allowing TypeScript examples to be added too?

This generator supports TypeScript code snippets, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add react-web generator Write React Components
9 participants